{extend name="../../base/view/layout" /}
{block name="my_body"}
<div class="maincontent">
    <div class="maincontentinner">

        <table id="dyntable" class="table table-bordered responsive">
            <thead>
            <tr>
                <th class="center"><input type="checkbox" class="checkall" /></th>
                <th class="center">订单ID</th>
                <th class="center">订单商品</th>
                <th class="center">订单总价</th>
                <th class="center">订单类型</th>
                <th class="center">订单状态</th>
                <th class="center">配送属性</th>
                <th class="center">客户留言</th>
                <th class="center">操作</th>
            </tr>
            </thead>
            <?php foreach($data['data'] as $k=>$v):?>
            <tbody>
            <tr><td></td><td colspan="8">店铺:<?php echo $k;?></td></tr>
            <?php foreach($v as $v1):?>
            <tr >
                <td class="aligncenter"><span class="center">
                            <input type="checkbox" />
                          </span></td>
                <td class="center "><?php echo $v1['order_id'];?></td>
                <td class="left ">
                    <?php foreach($v1['order_goods'] as $v2)
                    {
                        $val = '<p>商品名称：'.$v2['shop_name'].'</p>';
                        $shop_attr = json_decode($v2['shop_attr'],true);
                        $val .= '<p>商品属性:';
                        foreach($shop_attr as $v3)
                            {
                                $val .=$v3['attr_name'].':'.$v3['attr_value'].'  ';
                            }
                        $val .= '</p>';
                        $val .= '<p>价格  '.$v2['shop_price'].' * 数量  '.$v2['shop_num'].'</p>';
                        echo $val;
                        echo '<p>----------------------</p>';
                    }
                   ?>

                </td>
                <td class="center "><?php echo $v1['total_price'];?></td>
                <td class="center "><?php $v1['type'] == 1?$e = '订单':$e = '退单'; echo $e;?></td>
                <td class="center "><?php echo $v1['state'];?></td>
                <td class="center "><?php $v1['ps_attr'] == 1?$e = '配送':$e = '不配送'; echo $e;?></td>
                <td class="center "><?php echo $v1['message'];?></td>

                <td class="center">
                    <?php if($v1['ps_attr'] == 1 && $v1['type'] == 1):?>
                        <?php if($v1['state_id'] == 2 && $v1['is_fh'] == 1):?>
                        <a href="<?php echo url('kdsearch',['order_id'=>$v1['order_id']]);?>">查看物流</a>
                        <?php elseif($v1['state_id'] == 2 && $v1['is_fh'] == 0):?>
                        <a href="<?php echo url('fh',['order_id'=>$v1['order_id']]);?>">发货</a>
                        <?php endif;?>
                        <br />
                    <?php endif;?>

                    <?php if($v1['state_id'] == 1):?>
                    <a thisid="<?php echo $v1['order_id'];?>" href="javascript:;" onclick="cancle(this)">取消订单</a><br />
                    <?php endif;?>
                </td>
            </tr>
            <?php endforeach;?>

            </tbody>
            <?php endforeach;?>
        </table>

        <br /><br />
        <?php echo $data['page'];?>


    </div><!--maincontentinner-->
</div><!--maincontent-->
{/block}

{block name="my_js"}
<script>
    function cancle(t)
    {
        var order_id = jQuery(t).attr('thisid');
        var url = "<?php echo url('cancle');?>";
        jQuery.ajax({
            type: 'POST',
            url: url,
            data:"order_id="+order_id,
            dataType: 'JSON',
            success: function(res){
                if(res.code == 0)
                {
                    window. location.reload();
                }
                else
                {
                    var html = '<div class="widgetbox box-danger"><h4 class="widgettitle">错误提示 <a class="close">×</a> <a class="minimize">–</a></h4><div class="widgetcontent">'+res.msg+'</div></div>';
                    var h = jQuery(html);
                    jQuery(".maincontentinner").prepend(h);
                    window.setTimeout(function(){
                        h.remove();
                    },1000);
                }
            }
        })
    }
</script>
{/block}
